package com.qire.manhua.activity;

import android.os.Bundle;
import android.view.View;

import com.qire.antscore.annotation.RouteMapping;
import com.qire.antsrouter.AntsRouter;
import com.qire.antsrouter.lifecycleHandler.ActivityManageHandler;
import com.qire.common.constant.Navigation;
import com.qire.common.constant.TeensModeManage;
import com.qire.common.support.base.BaseActivity;
import com.qire.common.utils.ThemeUtil;
import com.qire.manhua.R;

import androidx.annotation.Nullable;

/**
 * 青少年模式休眠锁定页面(22~6点锁定页)
 */
@RouteMapping(path = Navigation.Page.TeensLockSleepPage)
public class TeensLockSleepActivity extends BaseActivity {

    @Override
    public int layoutRid() {
        return R.layout.activity_teens_lock_sleep;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ThemeUtil.changeStatusBarLightOrDark(this, true, true);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if(!TeensModeManage.teensModeEnable()) {
            finish();
        }
    }

    @Override
    public void finish() {
        if(!TeensModeManage.teensModeEnable()) {
            // 如果青少年模式开启状态中，则不可以关闭当前页面
            super.finish();
        }
    }

    @Override
    protected void onDestroy() {
        if(ActivityManageHandler.HANDLER.isLastOne()) {
            AntsRouter.ROUTER.buildCard(Navigation.Page.HomePage).navigation();
        }
        super.onDestroy();
    }

    public void closeTeensModeBtnOnClick(View view) {
        AntsRouter.ROUTER.buildCard(Navigation.Page.TeensModeTogglePage).navigation();
    }

}
